/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package byblos.apresentacao;

import java.io.IOException;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.SimpleTagSupport;

/**
 *
 * @author marano
 */
public class TagExibir extends SimpleTagSupport {

    private String caminho;
    private String largura;
    private String altura;

    public String getCaminho() {
        return caminho;
    }

    public void setCaminho(String caminho) {
        this.caminho = caminho;
    }

    public String getAltura() {
        return altura;
    }

    public void setAltura(String altura) {
        this.altura = altura;
    }

    public String getLargura() {
        return largura;
    }

    public void setLargura(String largura) {
        this.largura = largura;
    }

    private String escreverTag() {
        String caminho = this.caminho;
        String larguraTag;
        String alturaTag;
        if (largura != null) {
            larguraTag = " width=\"" + largura + "\"";
        } else {
            larguraTag = "";
        }
        if (altura != null) {
            alturaTag = " height=\"" + altura + "\"";
        } else {
            alturaTag = "";
        }
        if (caminho.toLowerCase().endsWith("swf")) {
            //275 110
            return "<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0\"" + larguraTag + alturaTag + " id=\"menu\" align=\"top\">" +
                    "<param name=\"allowScriptAccess\" value=\"sameDomain\" />" +
                    "<param name=\"allowFullScreen\" value=\"false\" />" +
                    "<param name=\"movie\" value=\"" + caminho + "\" />" +
                    "<param name=\"menu\" value=\"false\" />" +
                    "<param name=\"quality\" value=\"high\" />" +
                    "<param name=\"scale\" value=\"noscale\" />" +
                    "<param name=\"wmode\" value=\"transparent\" />" +
                    "<param name=\"devicefont\" value=\"true\" />" +
                    "<embed src=\"" + caminho + "\" menu=\"false\" quality=\"high\" scale=\"noscale\" wmode=\"transparent\" devicefont=\"true\"" + larguraTag + alturaTag + " name=\"menu\" align=\"top\" allowScriptAccess=\"sameDomain\" allowFullScreen=\"false\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" />" +
                    "</object>";
        } else {
            return "<img src=\"" + caminho + "\"" + larguraTag + alturaTag + " >";
        }
    }

    @Override
    public void doTag() throws JspException, IOException {
        getJspContext().getOut().write(escreverTag());
    }
}

